package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.SysLoginInfo;
import com.ruoyi.system.mapper.SysLoginInfoMapper;
import com.ruoyi.system.service.ISysLoginInfoService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 系统访问日志情况信息 服务层处理
 *
 * @author ruoyi
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class SysLoginInfoServiceImpl implements ISysLoginInfoService {

    @Resource
    SysLoginInfoMapper loginInfoMapper;

    /**
     * 新增系统登录日志
     *
     * @param loginInfo 访问日志对象
     */
    @Override
    public void insertLoginInfo(SysLoginInfo loginInfo) {
        this.loginInfoMapper.insertLoginInfo(loginInfo);
    }

    /**
     * 查询系统登录日志集合
     *
     * @param loginInfo 访问日志对象
     * @return 登录记录集合
     */
    @Override
    @Transactional(readOnly = true)
    public List<SysLoginInfo> selectLoginInfoList(SysLoginInfo loginInfo) {
        return this.loginInfoMapper.selectLoginInfoList(loginInfo);
    }

    /**
     * 批量删除系统登录日志
     *
     * @param infoIds 需要删除的登录日志ID
     * @return
     */
    @Override
    public int deleteLoginInfoByIds(Long[] infoIds) {
        return this.loginInfoMapper.deleteLoginInfoByIds(infoIds);
    }

    /**
     * 清空系统登录日志
     */
    @Override
    public void cleanLoginInfo() {
        this.loginInfoMapper.cleanLoginInfo();
    }

    @Override
    public String selectLastLoginByUserName(SysLoginInfo loginInfo) {
        return this.loginInfoMapper.selectLastLoginByUserName(loginInfo);
    }
}
